package com.beyond.framework.privilege.interceptor;

import com.beyond.framework.privilege.annotations.Privilege;
import com.beyond.framework.privilege.PrivilegeException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

/**
 * Created by IntelliJ IDEA.
 * User: lewisw
 * Date: Sep 8, 2010
 * Time: 10:31:07 AM
 */
@Aspect
public class SpringMVCInterceptor {

    @Pointcut("@annotation(com.beyond.framework.privilege.annotations.Privilege)")
    public void doAccessCheck() {
    }

    @Before("@annotation(privilege)")
    public void doAccessCheck(JoinPoint joinPoint, Privilege privilege) {
        if (notHave(privilege)) {
            throw new PrivilegeException();
        }
    }

    private boolean notHave(Privilege privilege) {
        return false;
    }
}
